package cj.web.admin.controllers;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import net.paoding.rose.web.annotation.Path;
import net.paoding.rose.web.annotation.rest.Get;
import net.paoding.rose.web.annotation.rest.Post;
import net.paoding.rose.web.var.Model;
import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import cj.web.admin.dao.SysInforDAO;
import cj.web.admin.domain.SysInfor;
import cj.web.login.controllers.BaseController;

@Path("/sysInfor")
public class SysInforController extends BaseController{

	private static Logger logger = Logger.getLogger(SysInforController.class.getName());
	
	@Autowired
	private SysInforDAO sysInforDao;
	
	@Get("showInfor")
	public String showInfor(Model model,SysInfor sysInfor) {
		return "/views/kly/sysInfo.vm";
	}
	
	@Get("show")
	public String show(Model model,SysInfor sysInfor) {
		return "/views/user/sysInfoList.vm";
	}

	@Post("getList")
	public String queryList(SysInfor sysInfor, HttpServletRequest request) {
		//当前页  
		sysInfor.setStart((sysInfor.getPage()-1)*sysInfor.getRows());
		sysInfor.setLength(sysInfor.getRows());
		sysInfor.setUserId(returnSessionObj(request).getId());
		List<SysInfor> objs = sysInforDao.query(sysInfor);

		JSONObject jo = new JSONObject();

		int size = sysInforDao.querySize(sysInfor);

		jo.put("rows", objs);
		jo.put("total", size);
		return "@" + jo.toString();
	}
}